package com.bdqn.biz;

import com.bdqn.dao.BaseDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;

@WebServlet(name = "ajax2", value = "/ajax2")
public class ajax2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        request.setCharacterEncoding("utf8");
        String title=request.getParameter("title");
        //判断数据库是否有title
        String sql="select * from newtable where title=?";
        String result="no";
        try {
            ResultSet set=BaseDao.getResultSet(sql,new Object[]{title});
            if(set.next())
            {
                result="ok";
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        //后台
        PrintWriter writer=response.getWriter();
        writer.write(result);

    }
}
